﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SalaryMS
{
    public partial class LoginUI : Form
    {
        public LoginUI()
        {
            InitializeComponent();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            String account = txtAccount.Text.Trim().ToString();
            String password = txtPassword.Text.Trim().ToString();
            if (account == null || account == "" || password == null || password == "")
            {
                MessageBox.Show("登陆名或者密码不能为空！");
            }
            else
            {
                String sql = "SELECT * FROM Administrators WHERE Name='" + account + "' AND Password='" + password + "';";
                DataTable dt = DBSession.ExecuteDataTable(sql, null);
                if (dt != null && dt.Rows.Count == 1)
                {
                    this.Hide();
                    new SalaryMS().Show();
                }
                else
                {
                    MessageBox.Show("登陆名或者密码错误，请重新输入！");
                }
            }
        }
    }
}
